package jsontool;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;

import java.io.Serial;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Date;
import java.util.Objects;

public class Student implements Serializable {
    @Serial
    private static final long serialVersionUID = -4808351325968790045L;

    private String name;
    private int age;

    @MyJsonIgnore//忽略字段
    private String sex;

    private String courses;
    private Integer scores;

    @MyJsonFormat(pattern = "yyyy-MM-dd")
    private Date birthday;

    public Student() {
    }

    public Student(String name, int age, String sex, String courses, Integer scores, Date birthday) {
        this.name = name;
        this.age = age;
        this.sex = sex;
        this.courses = courses;
        this.scores = scores;
        this.birthday = birthday;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String  getCourses() {
        return courses;
    }

    public void setCourses(String  courses) {
        this.courses = courses;
    }

    public Integer  getScores() {
        return scores;
    }

    public void setScores(Integer  scores) {
        this.scores = scores;
    }

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Student student = (Student) o;
        return age == student.age && Objects.equals(name, student.name) && Objects.equals(sex, student.sex) && Objects.equals(courses, student.courses) && Objects.equals(scores, student.scores) && Objects.equals(birthday, student.birthday);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, age, sex, courses, scores, birthday);
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", sex='" + sex + '\'' +
                ", courses='" + courses + '\'' +
                ", scores=" + scores +
                ", birthday=" + birthday +
                '}';
    }
}
